package com.chat.controller;

import com.chat.dto.UsersDto;
import com.chat.entity.Users;
import com.chat.vo.TokenVo;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("user")
@CrossOrigin
public class UserController {
    @Autowired
    private UsersDto usersDto;
    @PostMapping("login")
    public String login(@RequestBody Users users){
        return usersDto.login(users);
    }
    @GetMapping ("isLogin")
    public String login(@RequestHeader("token") String token){
        return usersDto.isLogin(token);
    }
    @PostMapping("reg")
    public String reg(@RequestBody Users users){
        return usersDto.reg(users);
    }
    @GetMapping("getUserInfo")
    public String getUserInfo(@RequestHeader("token") String token, @Param("username") String username){
        return usersDto.getUserInfo(token);
    }

}
